package com.zyl.blog.CogniSphere.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.reactive.function.client.WebClient;

/**
 * @version v1.0
 * @ProjectName: Personal_Blog_Server
 * @Package: com.zyl.blog.CogniSphere.config
 * @ClassName: SparkAiConfig
 * @Description:
 * @Author FinalFantasy
 * @Date 2025/8/15-10:31
 */
@Configuration
public class SparkAiConfig {

    @Value("${spark.ai.app-id}")
    private String appId;

    @Value("${spark.ai.api-key}")
    private String apiKey;

    @Value("${spark.ai.api-secret}")
    private String apiSecret;

    @Value("${spark.ai.base-url}")
    private String baseUrl;

    @Value("${spark.ai.http-base-url}")
    private String httpBaseUrl;

    @Value("${spark.ai.model}")
    private String model;

    @Value("${spark.ai.domain}")
    private String domain;

    @Value("${spark.ai.timeout}")
    private Integer timeout;

    @Bean
    public WebClient webClient() {
        return WebClient.builder()
                .baseUrl(baseUrl)
                .build();
    }

    @Bean
    public SparkAiProperties sparkAiProperties() {
        return new SparkAiProperties()
                .setAppId(appId)
                .setApiKey(apiKey)
                .setApiSecret(apiSecret)
                .setBaseUrl(baseUrl)
                .setHttpBaseUrl(httpBaseUrl)
                .setModel(model)
                .setDomain(domain)
                .setTimeout(timeout);
    }
}